extends Card

func init():
	att.cry = 1
	lv = 4
	type = TYPE.MAGIC
	camp = "m_all" 
	name = "迭代协议" 
	dec = "骰出一个六面骰子，根据点数将对应消耗的法术加入手牌并使其降为0费。" 
	aiTab = "back" 
	isUsable = false

func _use(card,cell):
	var q = sys.rndRan(1,6);
	var chag = []
	var chas = sys.game.cardRndPool.items
	var cantplus = false
	chas.shuffle()
	match q:
		1:
			for i in range(1):
				var card1 = sys.game.cardRndPool.rndItem(self,"rnd1")
				if card1 != null:
					var cha = getHero().newCard(card1.id)
					getHero().hand.addCard(cha)
					cha.att.cry = 0
					chag.append(cha)

		2:
			for i in range(1):
				var card1 = sys.game.cardRndPool.rndItem(self,"rnd2")
				if card1 != null:
					var cha = getHero().newCard(card1.id)
					getHero().hand.addCard(cha)
					cha.att.cry = 0
					chag.append(cha)
		3:
			for i in range(1):
				var card1 = sys.game.cardRndPool.rndItem(self,"rnd3")
				if card1 != null:
					var cha = getHero().newCard(card1.id)
					getHero().hand.addCard(cha)
					cha.att.cry = 0
					chag.append(cha)
		4:
			for i in range(1):
				var card1 = sys.game.cardRndPool.rndItem(self,"rnd4")
				if card1 != null:
					var cha = getHero().newCard(card1.id)
					getHero().hand.addCard(cha)
					cha.att.cry = 0
					chag.append(cha)
		5:
			for i in range(1):
				var card1 = sys.game.cardRndPool.rndItem(self,"rnd5")
				if card1 != null:
					var cha = getHero().newCard(card1.id)
					getHero().hand.addCard(cha)
					cha.att.cry = 0
					chag.append(cha)
		6:
			for i in range(1):
				var card1 = sys.game.cardRndPool.rndItem(self,"rnd6")
				if card1 != null:
					var cha = getHero().newCard(card1.id)
					getHero().hand.addCard(cha)
					cha.att.cry = 0
					chag.append(cha)

func rnd1(card:Card):
	if card.type == Card.TYPE.MAGIC && card.att.cry == 1 && card != self:
		return true
	return false

func rnd2(card:Card):
	if card.type == Card.TYPE.MAGIC && card.att.cry == 2 && card != self:
		return true
	return false

func rnd3(card:Card):
	if card.type == Card.TYPE.MAGIC && card.att.cry == 3 && card != self:
		return true
	return false

func rnd4(card:Card):
	if card.type == Card.TYPE.MAGIC && card.att.cry == 4 && card != self:
		return true
	return false

func rnd5(card:Card):
	if card.type == Card.TYPE.MAGIC && card.att.cry == 5 && card != self:
		return true
	return false
func rnd6(card:Card):
	if card.type == Card.TYPE.MAGIC && card.att.cry == 6 && card != self:
		return true
	return false